#include "framwork.h"
#include "queue.h"

QueueHandle_t commHdl = xQueueCreate(10, sizeof(fram_msg_t));
QueueHandle_t commThmt = xQueueCreate(10, sizeof(fram_msgData_t));

void comm_msg_dispatch(const fram_taskNum_e taskNum, const void *msgData)
{
    switch (taskNum)
    {
        case FRAM_TASK_THMT:
        {
            xQueueSend(commThmt, msgData, 0);
            break;
        }
        default :
        {
            LOG_INFO("|COMM|err tasknum %d\n", taskNum);
        }
    }
}

void comm_task(void)
{
    fram_msg_t commMsg;
    for (;;)
    {
        if (pdPASS == xQueueReceive(commHdl, &commMsg, 100))
        {
            if (FRAM_TGT_EVENT == commMsg.task_type)
            {
                comm_msg_dispatch(commMsg.task_num, &commMsg.msg);
            }
            else if (FRAM_TGT_LOOP == commMsg.task_type)
            {
            }
            else
            {
                LOG_INFO("|COMM|err tgt type %d\n", commMsg.task_type);
            }
        }
    }
}



